<%@ page language="java" import="java.util.*,com.fescoservice.model.*" pageEncoding="UTF-8"%>

<%
	String langfilename = "/resources/message";
	CategoryId categoryId =(CategoryId) request.getAttribute("categoryId");
	BBS viewBBS =(BBS) request.getAttribute("viewBBS");
	BBSContent viewBBSContent =(BBSContent) request.getAttribute("viewBBSContent");
	List attachments =(List) request.getAttribute("viewBBSAttaches");
%>
<%@include file="../common/LocaleManager.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		
		<title>Add Content</title>
		<link rel="stylesheet" href="<%=path%>/js/jquery/themes/redmond/jquery.ui.all.css">
		<script src="<%=path%>/js/jquery/jquery-1.5.1.js"></script>
		<script src="<%=path%>/js/jquery/external/jquery.bgiframe-2.1.2.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.core.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.widget.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.mouse.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.button.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.draggable.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.position.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.resizable.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.effects.core.js"></script>
		<script src="<%=path%>/js/jquery.MultiFile.js"></script>
		<script src="<%=path%>/js/kindeditor/kindeditor.js"></script>
		<link rel="stylesheet" type="text/css" href="<%=path%>/css/admin.css">
	
		<script>
			 KE.show({
					id : 'content1',
					//cssPath : '<%=path%>/js/kindeditor/skins/default.css',
					afterCreate : function(id) {
						KE.event.ctrl(document, 13, function() {
							KE.sync(id);
							document.forms.BBSId.submit();
							//document.forms.BBSId.content.value="";
						});
						KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {
							KE.sync(id);
							document.forms.BBSId.submit();
						});
					}
				});
			$(function(){
			 	$("#btnSave").button().click(function() {
						document.forms.BBSId.action = '<%=path%>/action/Content.htm?cmd=<%=(null!=viewBBS)?"modify":"add" %>';	
						document.forms.BBSId.content.value="";
						document.forms.BBSId.submit();		
					});
				$("#btnBack").button().click(function() {
						document.forms.BBSId.action = '<%=path%>/action/Category.htm?cmd=viewDetail';		
						document.forms.BBSId.submit();		
					});
			  
				 
			  $("#input:file.multi").MultiFile({  
			       accept:'gif|jpg|png|jpeg|bmp|doc|xls',
			       max:6, 
			       STRING: {  
			       remove:'删除',  
			       selected:'Selecionado: $file',  
			       denied:'不支持上传该文件类型 $ext!'  
			      }  
			    });
			});
	
			function save(){
				document.forms.BBSId.action = '<%=path%>/action/Content.htm?cmd=<%=(null!=viewBBS)?"modify":"add" %>';	
				document.forms.BBSId.content.value="";
				
				//document.forms.BBSId.filecount.value="";
				document.forms.BBSId.submit();
			}
		</script>
		<style>
			form {
				margin: 0;
			}
			textarea {
				display: block;
			}
			.ke-container{
				background-color:#deeffc;
			}
			.ke-icon{
				border-color:#deeffc;
			}
			.ke-icon-on{
				border-color:#5690e2;
			}
			.MultiFile-wrap{
				border: 2px solid #deeffc;
				padding: 10px 10px 10px 10px;
				width:670px;
			}
			.MultiFile-wrap .MultiFile-label a,.MultiFile-wrap .MultiFile-label a:hover{
				text-decoration: none;
				color: #deeffc;
			}
		</style>
	</head>
	<body>
		
		<form name="BBSId" method="post" action="" enctype="multipart/form-data">
			<%=resource.getString("FS_T_TITLE")%> : <input type="text" name="title" value="<%=(null!=viewBBS)?viewBBS.getTitle():"" %>" />
			 <input type="hidden" name="boardCode1" value="<%=categoryId.getBoardCode1() %>" />
			 <input type="hidden" name="boardCode2" value="<%=categoryId.getBoardCode2() %>" />
			 <input type="hidden" name="boardCode3" value="<%=categoryId.getBoardCode3() %>" />
			  <input type="hidden" name="boardSeq" value="<%=(null!=viewBBS)?viewBBS.getId().getBoardSeq():""  %>" />
			 <input type="hidden" name="content" />
			 <input type="hidden" name="filecount" value="0" />
			 <input type="hidden" name="filestring" />
			<br />
			<textarea id="content1" name="content1" style="width:700px;height:300px;visibility:hidden">
				<%=(null!=viewBBSContent)?viewBBSContent.getContent():"" %>
			</textarea>
			<br />
			
			<input type="file" id="fileupload" name="file" class='multi' />
			<%if(null!=viewBBS && viewBBS.getAttachYn().equals("Y")){
				BBSAttach attach = null;
				for(int i=0;i<attachments.size();i++){
				attach = (BBSAttach)attachments.get(i);
			%>
				<div><%=attach.getRealName() %></div>
			<%} 
			}%>
			<br/>
			<div class="buttonGroupRight">
				<div id="btnSave" ><%=resource.getString("FS_T_SAVE")%></div>
				<div id="btnBack" ><%=resource.getString("FS_T_BACK")%></div>
			</div>
		</form>
	</body>
</html>
